﻿if (typeof(Admin) == 'undefined')
    Admin = {};

Admin.GroupNews = {
    _options: {
        id: 'gridList',
        url: function () {
            var ret = "Service/ListGroupNews.ashx?key=e"
            return ret;
        }
    },
    ManipulateData: function (options) {
        var obj = $("#" + options.id + " > tbody");
        var data = new TIO().ajax(options.url());
        var result = "";
        for (i = 0; i < data.length; i++) {
            var item = data[i];
            result += $.Format(_format, item.Id, item.Name);
        }
        obj.html(result);
    },
    Edit: function (gnid) {
        var height = window.screen.height - 130;
        window.open("EditGroupNews.aspx?gnid=" + gnid, "_blank", "resizable=1,width=770,height=" + height);
    },
    Delete: function (gnid) {
        var data = new TIO().ajax("Service/DeleteGroupNews.ashx?gnid=" + gnid);
    },
    Init: function () {
        this.ManipulateData(this._options);
    }
}

$(function () {
    Admin.GroupNews.Init();
});

_format = "<tr>" + 
"<td class='a-center'>{0}</td>" +
"<td><a href='#'>{1}</a></td>" +
"<td>" +
    "<a pid='{0}' href='#'><img src='../../img/icons/user.png' title='Show detail' width='16' height='16' /></a>" +
    "<a pid='{0}' href='javascript:Admin.GroupNews.Edit({0});'><img src='../../img/icons/user_edit.png' title='Edit GroupNews' width='16' height='16' /></a>" +
    "<a pid='{0}' href='javascript:Admin.GroupNews.Delete({0});'><img src='../../img/icons/user_delete.png' title='Delete GroupNews' width='16' height='16' /></a>" +
"</td>" +
"</tr>";